// 引入饼图组件
import 'echarts/lib/chart/pie';
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/legend';
import echarts from 'echarts/lib/echarts';

export default {
  data() {
    return {
      pieChartColorArray: ['#ff5952', '#2898ff', '#ffcc00', '#ff8500', '#a56ff7', '#ffaf00'],
    };
  },
  methods: {
    drawPieChart(id, seriesData) {
      const myChart = echarts.init(document.getElementById(id));
      const chartOptions = {
        legend: {
          selectedMode: false,
          show: false
        },
        series: {
          type: 'pie',
          clickable: false,
          selectedMode: false,
          pieselectchanged: false,
          legendHoverLink: false,
          radius: ['60%', '90%'],
          center: ['50%', '50%'],
          hoverAnimation: false,
          label: {
            show: true
          },
          color: this.pieChartColorArray,
          itemStyle: {
            normal: {
              label: {
                show: false
              },
              labelLine: {
                show: false
              },
            },
            emphasis: {
              label: {
                show: false
              }
            }
          },
          data: seriesData
        }
      };
      myChart.setOption(chartOptions);
    }
  }
};